/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tiebreak.DAL;



import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
/**
 *
 * @author Henrik
 */
import java.sql.SQLException;
import sun.security.jca.GetInstance;
public class TBConnection
{

    /**
     * Create connection to the database, according to the information listed below.
     * @return
     * @throws SQLServerException
     */
    private static String serverName = "87.55.11.78";
    private static String dbName = "tie-break";
    private static int port = 3306;
    private static String user = "java";
    private static String pass = "java";
    private static TBConnection instance;
    
    private TBConnection()
    {
        try
        {
            Class.forName("org.gjt.mm.mysql.Driver");
        }
        catch (Exception E)
        {
            System.err.println("Unable to load driver");
            E.printStackTrace();
        }
    }


    public static TBConnection getInstance()
    {
        if(instance==null)
            instance=new TBConnection();
        return instance;
    }
    public static Connection getConnection() throws SQLException
    {
        return getInstance().getIConnection();
        

    }
    
    private Connection getIConnection() throws SQLException
    {
        java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://" + serverName + ":" + port + "/" + dbName, user, pass);

        return (Connection) con;
    }
}
